package framework.utils;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.Log;

import com.tetris.project.R;
import com.tetris.project.Shr_Res;

import framework.utils.ResourceManager.Type;

public class GlobalManager {

	public static ResourceManager<Drawable> DrawablesManager;
	public static int[] mDrawableResources = {
		R.drawable.blue,
		R.drawable.green,
		R.drawable.red,
		R.drawable.yellow,
		R.drawable.purple,
	};

	public static Context GlobalContext = null; 
	//Should add any other type of resources
	static GlobalManager self;
	String icons[];

	public static GlobalManager init(Context context)
	{
		self = new GlobalManager(context);
		return self;
	}

	protected GlobalManager(Context context)
	{
		GlobalContext = context;
		icons = GlobalContext.getResources().getStringArray(R.array.iconsValues);
		mDrawableResources = new int[5];
		getDrawables();
		DrawablesManager = new ResourceManager<Drawable>();
		DrawablesManager = DrawablesManager.getInstance(mDrawableResources, Type.DRAWABLE);
	}

	private void getDrawables(){
		if(Shr_Res.icon.equalsIgnoreCase(icons[0])){
			Log.d(Shr_Res.TAG, "Setting Icons to "+icons[0]);
			mDrawableResources[0] = R.drawable.block_blue;
			mDrawableResources[1] = R.drawable.block_green;
			mDrawableResources[2] = R.drawable.block_red;
			mDrawableResources[3] = R.drawable.block_yellow;
			mDrawableResources[4] = R.drawable.block_purple;
		}
		else if(Shr_Res.icon.equalsIgnoreCase(icons[1])){
			Log.d(Shr_Res.TAG, "Setting Icons to "+icons[1]);
			mDrawableResources[0] = R.drawable.cube_blue;
			mDrawableResources[1] = R.drawable.cube_green;
			mDrawableResources[2] = R.drawable.cube_red;
			mDrawableResources[3] = R.drawable.cube_yellow;
			mDrawableResources[4] = R.drawable.cube_purple;
		}
		else if(Shr_Res.icon.equalsIgnoreCase(icons[2])){
			Log.d(Shr_Res.TAG, "Setting Icons to "+icons[2]);
			mDrawableResources[0] = R.drawable.faces_blue;
			mDrawableResources[1] = R.drawable.faces_green;
			mDrawableResources[2] = R.drawable.faces_red;
			mDrawableResources[3] = R.drawable.faces_yellow;
			mDrawableResources[4] = R.drawable.faces_purple;
		}
		else if(Shr_Res.icon.equalsIgnoreCase(icons[3])){
			Log.d(Shr_Res.TAG, "Setting Icons to "+icons[3]);
			mDrawableResources[0] = R.drawable.mushroom_blue;
			mDrawableResources[1] = R.drawable.mushroom_green;
			mDrawableResources[2] = R.drawable.mushroom_red;
			mDrawableResources[3] = R.drawable.mushroom_yellow;
			mDrawableResources[4] = R.drawable.mushroom_purple;
		}		
		else if(Shr_Res.icon.equalsIgnoreCase(icons[4])){
			Log.d(Shr_Res.TAG, "Setting Icons to "+icons[4]);
			mDrawableResources[0] = R.drawable.mushroom_blue;
			mDrawableResources[1] = R.drawable.mushroom_green;
			mDrawableResources[2] = R.drawable.mushroom_red;
			mDrawableResources[3] = R.drawable.mushroom_yellow;
			mDrawableResources[4] = R.drawable.mushroom_purple;
		}
		else if(Shr_Res.icon.equalsIgnoreCase(icons[5])){
			Log.d(Shr_Res.TAG, "Setting Icons to "+icons[5]);
			mDrawableResources[0] = R.drawable.piramid_blue;
			mDrawableResources[1] = R.drawable.piramid_green;
			mDrawableResources[2] = R.drawable.piramid_red;
			mDrawableResources[3] = R.drawable.piramid_yellow;
			mDrawableResources[4] = R.drawable.piramid_purple;
		}
		else if(Shr_Res.icon.equalsIgnoreCase(icons[6])){
			Log.d(Shr_Res.TAG, "Setting Icons to "+icons[6]);
			mDrawableResources[0] = R.drawable.skittles_blue;
			mDrawableResources[1] = R.drawable.skittles_green;
			mDrawableResources[2] = R.drawable.skittles_red;
			mDrawableResources[3] = R.drawable.skittles_yellow;
			mDrawableResources[4] = R.drawable.skittles_purple;
		}
		else if(Shr_Res.icon.equalsIgnoreCase(icons[7])){
			Log.d(Shr_Res.TAG, "Setting Icons to "+icons[7]);
			mDrawableResources[0] = R.drawable.skull_blue;
			mDrawableResources[1] = R.drawable.skull_green;
			mDrawableResources[2] = R.drawable.skull_red;
			mDrawableResources[3] = R.drawable.skull_yellow;
			mDrawableResources[4] = R.drawable.skull_purple;
		}
		else if(Shr_Res.icon.equalsIgnoreCase(icons[8])){
			Log.d(Shr_Res.TAG, "Setting Icons to "+icons[8]);
			mDrawableResources[0] = R.drawable.sphere_blue;
			mDrawableResources[1] = R.drawable.sphere_green;
			mDrawableResources[2] = R.drawable.sphere_red;
			mDrawableResources[3] = R.drawable.sphere_yellow;
			mDrawableResources[4] = R.drawable.sphere_purple;
		}
		else if(Shr_Res.icon.equalsIgnoreCase(icons[9])){
			Log.d(Shr_Res.TAG, "Setting Icons to "+icons[9]);
			mDrawableResources[0] = R.drawable.square_blue;
			mDrawableResources[1] = R.drawable.square_green;
			mDrawableResources[2] = R.drawable.square_red;
			mDrawableResources[3] = R.drawable.square_yellow;
			mDrawableResources[4] = R.drawable.square_purple;
		}
		else {
			Log.d(Shr_Res.TAG, "Setting Icons to Default");
			mDrawableResources[0] = R.drawable.block_blue;
			mDrawableResources[1] = R.drawable.block_green;
			mDrawableResources[2] = R.drawable.block_red;
			mDrawableResources[3] = R.drawable.block_yellow;
			mDrawableResources[4] = R.drawable.block_purple;
		}
	}
}
